package com.stargate.bd.bean;

import java.sql.Date;

public class Entree {

	/** CONSTANTES SQL */
	public static final String TABLE_NAME = "ENTREE";
	public static final String NUM_ACCES = "NumAcces";
	public static final String CODE_BATIMENT = "Code_Batiment";
	public static final String CODE_POINT_ACCES = "CodePointAcces";
	public static final String ETAT_ENTREE = "Etat_Entree";
	public static final String DATE_ENTREE = "Date_Entree";

	private int numAcces;
	private String codeBatiment;
	private String codePointAcces;
	private Etat etatEntree;
	private Date dateEntree;

	public Entree(int numAcces, String codeBatiment, String codePointAcces,
			Etat etatEntree, Date dateEntree) {
		this.numAcces = numAcces;
		this.codeBatiment = codeBatiment;
		this.codePointAcces = codePointAcces;
		this.etatEntree = etatEntree;
		this.dateEntree = dateEntree == null ?
				FormatDate.dateSystemSQL() : dateEntree;
	}

	public Entree(int numAcces, String codeBatiment, String codePointAcces,
			Etat etatEntree) {
		this.numAcces = numAcces;
		this.codeBatiment = codeBatiment;
		this.codePointAcces = codePointAcces;
		this.etatEntree = etatEntree;
		dateEntree = FormatDate.dateSystemSQL();
	}

	public int getNumAcces() {
		return numAcces;
	}

	public void setNumAcces(int numAcces) {
		this.numAcces = numAcces;
	}

	public String getCodeBatiment() {
		return codeBatiment;
	}

	public void setCodeBatiment(String codeBatiment) {
		this.codeBatiment = codeBatiment;
	}

	public String getCodePointAcces() {
		return codePointAcces;
	}

	public void setCodePointAcces(String codePointAcces) {
		this.codePointAcces = codePointAcces;
	}

	public Etat getEtatEntree() {
		return etatEntree;
	}

	public void setEtatEntree(Etat etatEntree) {
		this.etatEntree = etatEntree;
	}

	public Date getDateEntree() {
		return dateEntree;
	}

	public void setDateEntree(Date dateEntree) {
		this.dateEntree = dateEntree;
	}

	@Override
	public String toString() {
		return "Entree[" + numAcces + ", " +
				codeBatiment + ", " +
				etatEntree.etat + ", " +
				dateEntree.toString() + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Entree) {
			Entree e = (Entree) obj;
			return numAcces == e.numAcces 
					&& codeBatiment.equals(e.codeBatiment)
					&& codePointAcces.equals(e.codePointAcces);
		} else {
			return false;
		}
	}
}
